//
//  AiRoleBean.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/1/8.
//

import Foundation
import LeanCloud
import GRDB

//目录
class CloudFolderBean : ICloudTable,IDbTable, Identifiable {
    
    static let databaseTableName = "folder"

    func getCloudTable() -> String {
        return "CloudFolder"
    }
    
    //leanCloud 排除字段
    func doCustomExcluded() -> [String? : Any?] {
        return doExcluded(subject: self, excluded: ["id, createTime","updateTime","modifySign","status"])
    }
    
    //db排除字段
    func doCustomDBExcluded()  -> [String? : Any?] {
        return doExcluded(subject: self, excluded: [""])
    }
    
    init(userId : String){
        self.userId = userId
    }
    
    var objectId: String?
    var userId:String?
    var time: Int64 = 0
    var letterNum: String? = nil//字母数值
    var doubleRow: Bool = true
    var spanCount: Int = 4//格子试图数量
    var sort: Int = 0
    var title: String? = nil
    var sortNum: Int = 0//排序值，自定义的排序值
    var parentId: String? = nil//父类id
    var name: String = ""
    var count: Int = 0
    var coverFileId: String? = nil//封面的FileId 唯一标识，常用于阿里
    var coverTime: Int64 = 0 //封面过期时间
    var cover: String = ""//封面
    var iconType: Int = 0 //特殊图标-目前有音频
    var isHideCover: Bool = false//是否隐藏封面
    
    
    var createTime: TimeInterval = 0//创建时间
    var updateTime: TimeInterval = 0//更新时间时间
    var modifySign: Bool = false//修改标识
    var status: Int = IStatusType.NORMAL.rawValue
    
    //json解析白名单
    private enum CodingKeys: String, CodingKey {
        case objectId
        case userId
        case time
        case letterNum
        case doubleRow
        case spanCount
        case sort
        case title
        case sortNum
        case parentId
        case name
        case count
        case coverFileId
        case coverTime
        case cover
        case iconType
        case isHideCover
        //        case createTime
        //        case updateTime
        //        case modifySign
        //        case status
    }
}



extension CloudFolderBean {
    // db数据库指定字段
    public func encode(to container: inout PersistenceContainer) {
        doDBExcluded(to: &container)
    }
}
